/* 
 * PROJECT: FLARManager
 * http://transmote.com/flar
 * Copyright 2009, Eric Socolofsky
 * --------------------------------------------------------------------------------
 * This work complements FLARToolkit, developed by Saqoosha as part of the Libspark project.
 *	http://www.libspark.org/wiki/saqoosha/FLARToolKit
 * FLARToolkit is Copyright (C)2008 Saqoosha,
 * and is ported from NYARToolkit, which is ported from ARToolkit.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this framework; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * For further information please contact:
 *	<eric(at)transmote.com>
 *	http://transmote.com/flar
 * 
 */

package com.transmote.flar.marker {
	import flash.geom.Point;
	
	import org.libspark.flartoolkit.core.FLARSquare;
	import org.libspark.flartoolkit.core.labeling.FLARLabelingLabel;
	
	/**
	 * wrapper for FLARSquare that provides:
	 * - centerpoint of outline;
	 * - a more accurately descriptive name.
	 * 
	 * @author	Eric Socolofsky
	 * @url		http://transmote.com/flar
	 */
	public class FLARMarkerOutline extends FLARSquare {
		internal var _centerpoint:Point;
		
		/**
		 * constructor.
		 */
		public function FLARMarkerOutline (line:Array, sqvertex:Array, imvertex:Array, label:FLARLabelingLabel) {
			super();
			this.line = line;
			this.sqvertex = sqvertex;
			this.imvertex = imvertex;
			this.label = label;
			
			this._centerpoint = new Point(
					0.25 * (this.sqvertex[0].x + this.sqvertex[1].x + this.sqvertex[2].x + this.sqvertex[3].x),
					0.25 * (this.sqvertex[0].y + this.sqvertex[1].y + this.sqvertex[2].y + this.sqvertex[3].y));
		}
		
		/**
		 * centerpoint of marker outline;
		 * calculated as average of four corner points.
		 */
		public function get centerpoint () :Point {
			return this._centerpoint;
		}
	}
}